/*
@title: Penny Platformer
@description: Penny Platformer is a three-level platform game featuring assets from the Penny's Big Breakaway asset pack. Players control Penny, the main character, as they collect coins while navigating levels filled with obstacles, avoiding penguins along the way. The game is part of a competition where community-voted entries can win a copy of Penny's Big Breakaway for Windows or Linux.
@author: Bright Li
@tags: []
@addedOn: 2024-04-23

If you build a game using assets from the new Penny's Big Breakaway asset pack, 
the top 5 games as voted by the community will receive a free copy of Penny's Big Breakaway 
on Windows (or Linux via Proton!)

You can participate whether or not you have a Sprig console already.

Submission requirements:
- Meet the Sprig gallery requirements found here -> (https://github.com/hackclub/sprig/blob/main/docs/GET_A_SPRIG.md)
- Your game takes advantage of the Penny's Big Breakaway asset pack:
  - It must use the character model of Penny as a player character within the game
  - (Optional) Also use the penguins as the main antagonist within the game
- On April 19th, all games merged into the Sprig repository with the tag #penny will 
    be shared by the Sprig team in #sprig on the Hack Club Slack to be voted on for 24 hours.

The top 5 voted games will receive a Steam key!

Below are the assets of Penny's Big Breakaway you can use!
*/

const p_head1 = 'p'; //pennyHead1
const p_stand = 's'; //pennyStand
const p_step1 = 'w'; //pennyStep1
const p_jump2 = 'J'; //pennyJump2
const p_swing = 'S'; //pennySwing
const p_head2 = 'P'; //pennyHead2(Jump)
const p_jump1 = 'j'; //pennyJump1
const p_head3 = 'C'; //pennyHead3
const p_step2 = 'W'; //pennyStep2
const p_hat = 'r'; //pennyHat
const p_ride1 = 'R'; //pennyRide1
const p_ride2 = 'y'; //pennyRide2
const p_yoyo = 'Y'; //pennyYoYo
const bar_top = 'Í'; //barrelTop
const bar_body = 'Î'; //barrelBody
const bush_left = 'Ï'; //bushLeft
const crate = 'Ð'; //crate
const bush_right = 'Õ'; //bushRight
const coin = 'Ú'; //coin
const grass1 = 'ã'; //grass1
const grass2 = 'ä'; //grass2
const grass3 = 'å'; //grass3
const grass4 = 'ê'; //grass4
const grass5 = 'ë'; //grass5
const grass6 = 'ì'; //grass6
const grass7 = 'î'; //grass7
const grass8 = 'ï'; //grass8
const grass9 = 'ð'; //grass9
const string1 = 'ĳ'; //string1 
const string2 = 'Ĵ'; //string2
const string3 = 'ĵ'; //string3
const t_pen_head_stand = "Ů"; //tallPenguinHeadStand
const t_pen_body_stand = "Ű"; //tallPenguinBodyStand
const t_pen_head_walk = "Ų"; //tallPenguinHeadWalk
const t_pen_body_walk1 = "Ŵ"; //tallPenguinBodyWalk1
const t_pen_body_walk2 = "ŵ"; //tallPenguinBodyWalk2
const m_pen_body_stand = "Ÿ"; //miniPenguinBodyStand
const m_pen_head_stand = "ź"; //miniPenguinHeadStand
const m_pen_head_walk = "z";
const m_pen_body_walk1 = "ż"; //miniPenguinBodyWalk1
const m_pen_body_walk2 = "Ž"; //miniPenguinBodyWalk2
const emperor1 = "ž"; //emperor1
const emperor2 = "ſ"; //emperor2
const emperor3 = "ƀ"; //emporer3
const emperor4 = "Ɓ"; //emporer3
const bg = "b"; //BACKGROUND FOR EXAMPLE PROJECT

setLegend(
  [p_head1, bitmap`
................
5F....5F........
56F...5F........
5666.55FF.......
5666655FF.......
5666665FFF......
5F666666FFF.....
556666666FFF....
5566666666FFFF..
256266666666FFF6
2252266666666661
2211226666666622
.122129LL99LL222
222212L259952L22
2212192279972121
.2212999C999992.`],
  [p_stand, bitmap`
11223C999CC99C11
1133331555533C11
1133335555553C11
11315FF66666F511
11355F6666666553
113353F66666F533
1133331133333333
113399566666F993
11C3996666666991
L11L566666666661
.111F6666115666L
.L111555F.1F55L.
......9.....9...
.....333...333..
......3.....3...
.....555....555.`],
  [p_step1, bitmap`
11223C999CC99C11
1133331555533C11
1133555555553C99
113555F66666F599
13335F6666666553
133333F66666F533
1139931133333331
1139935666666F11
11C33C6666666661
L11L566666666661
.1115666611F551L
.L111555F.1191L.
......9....333..
.....333....3...
......3.....555.
.....555........`],
  [p_head2, bitmap`
5F....5F........
56F...5F........
5666.55FF.......
5666655FF.......
5666665FFF......
5F666666FFF.....
556666666FFF....
2562666666FFFF..
226226666666FFF6
2211226666666622
.122129L5995L222
222212L279972L22
2212192229922121
L2212999C999992L
1222LC999CC99C12
12C33C155553CL11`],
  [p_jump1, bitmap`
1133335555553L11
11335FF66666F551
11335F6666666533
133353F66666F333
1993131133333399
1993335566665599
1133355F6666F551
113335F666666551
11C33566666F9L11
L11LL96666333311
.11391F66115311L
.L5331L...1555L.
..555.......55..
...55...........
................
................`],
  [p_jump2, bitmap`
11223C999CC99C99
1133335555F33399
1135555555533333
11555F66666F5331
1135F66666665C11
11333F66666F3C11
1139931333C33C11
11399556666F3C11
11C355F66666CL11
L11L5F666666L111
.11156666F61111L
.L1196666F6111L.
..39.F66F6......
.533.399........
.555.555........
..55.55.........`],
  [p_head3, bitmap`
................
................
5F....5F........
56F...5F........
5666.55FF.......
5666655FF.......
5666665FFF......
5F666666FFF.....
556666666FFF....
5566666666FFFF..
256266666666FFF6
2252266666666661
2211226666666622
L122129LL99LL222
222212L259952L22
2212192279972121`],
  [p_step2, bitmap`
12212999C9999921
11223C999CC99C11
1133555555553C11
113553996666F511
1135339966666551
113333366666F331
1133331133333399
11333356666F3C99
11C335666666FL11
L11LL56666666111
.11111555F66611L
.L1111L9..5511L.
......333.9.....
.......3.333....
......555.3.....
..........555...`],
  [p_swing, bitmap`
..22.C999CC99C99
......5555...399
...55555555.3333
..555F66666F533.
..35F66666665...
..333F66666F....
..399..333......
...99556666F....
....55F66666....
....5F666666....
....56666F6.....
....96666F6.....
..39.F66F6......
.533.399........
.555.555........
..55.55.........`],
  [p_hat, bitmap`
................
................
................
................
................
................
................
................
................
56F...5F........
5666.55FF.......
5666655FF.......
5666665FFF......
5F666666FFF.....
556666666FFF....
5566666666FFFF..`],
  [p_ride1, bitmap`
256266666666FFF.
225226666666666.
221122666666662.
.122129LL99LL22.
222212L259952L2.
221219227997212.
92212999C999992.
.332.C999CC99C..
.33335.5555.....
...35555555553..
....55F66666F5..
.....F666666653.
55....F66666F33.
55......333.99..
33...556666F.9..
395655F666662...`],
  [p_ride2, bitmap`
.L1111L6666621L.
L121112L6661212L
121LL11266621112
12C33C116612CL11
11333311FF213L11
11333311F6233C11
1133331166133C11
1131L31166633C11
113L131166633C11
11333311F6F33C11
11333311CFC33C11
11333311CC333C11
11C33C11CC33CL11
L11LL111C33CL111
.111111L.111111L
.L1111L...1111L.`],
  [p_yoyo, bitmap`
.L1111LC.L1111L.
L121112LC3L1112L
121LL112C33CL112
12C33C11CC33CL11
11333311CFC33L11
11333311F6F33C11
1133331166633C11
1131L31166633C11
113L131166633C11
11333311F6F33C11
11333311CFC33C11
11333311CC333C11
11C33C11CC33CL11
L11LL111C33CL111
.111111L.111111L
.L1111L...1111L.`],
[ bar_top, bitmap`
................
................
................
................
................
................
................
................
................
................
................
...L5555555555..
..5555557777555.
.575577555555755
5775577555555775
5555555555555555` ],
[ bar_body, bitmap`
.55CC55C33333C5.
..LCCL133222231.
..LCCL13333C231.
..LCCL133333331.
..LCCL133333231.
..LCCL133333231.
..LCCL133333331.
..LCCL133333331.
..LCCL133333331.
..LCCL133333331.
..LCCL133333331.
.55CC55C33333C5.
5555555555555555
5775577555555775
.57557755555575.
..555555777755..` ],
[ bush_left, bitmap`
................
................
................
................
........DDDDDDD.
......DDDDDDDDDD
.....DDDDDDDDHHD
....DDDDDDDDHLHD
...DDDDDDDDDHHDD
..DDDDDDDDDDDDDD
..DDDDDDDDDDDDDD
.DDDHHDDDDDDDDDD
.DDDHLHDDDDDDDDD
.DDDDHHDDDDDDDDD
.DDDDDDDDDDDDDDD
.DDDDDDDDDDDDDDD` ],
[ crate, bitmap`
C9C9C9C11119C9CL
C9C9CL1111C9C9C1
C9C9C1111LC9CL11
C9CL1111C9C9C111
C9C1111LC9CL1111
CL1111C9C9C11111
C1111LC9CL11111L
1111C9C9C11111C9
C9C9C9CL11111LC1
C9C9C9C11111C911
C9C9CL11111LC111
C9C9C11111C9111L
C9CL111119C111C9
C9C11111CL111LC9
CL11111LC111C9C9
C11111C9111LC9C9` ],
[ bush_right, bitmap`
................
................
................
................
................
D...............
DD..............
DDD.............
DDDD............
DDDDDDDDD.......
DDDDDDDHHDD.....
DDDDDDHLHDDD....
DDDDDDHHDDDDD...
DDDDDDDDDDDDDD..
DDDDDDDDDDDDDDD.
DDDDDDDDDDDDDDD.` ],
[ coin, bitmap`
................
................
................
.....122221.....
....12F6F221....
....22622F22....
....2F66F2F2....
....266.66F2....
....262.66F2....
....2F66F6F2....
....22666F22....
....12F6F221....
.....122221.....
................
................
................` ],
[ grass1, bitmap`
..44444444444444
.444466444444444
44446F6444664444
44446644446F6444
4444444444466444
444444FDF4444444
44444FDDDF444444
444FDDDDDDDF4444
44DDDDDDDDDDDDDD
44DDDDDDDDDDDDDD
4DDDDDDDDDDDDDDD
DDDDDDDDDDDDDDDD
CCCDDDCCCCCDDDCC
CCCCDCCCCCCCDCCC
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC` ],
[ grass2, bitmap`
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC
DCCCCCCCCCCCCCCC
DCCCCCCCCCCCCCCC
DDCCCCCCCCCCCCCC
DCCCCCCCCCCCCCCC
DCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC
DCCCCCCCCCCCCCCC
DCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC` ],
[ grass3, bitmap`
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC
DDCCCCCCCCCCCCCC
DCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC
DCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC
.CCCCCCCCCCCCCC.
..CCCCCCCCCCC...` ],
[ grass4, bitmap`
4444444444444444
4466444446644444
46F6444446F64444
4664444444664444
4444444444444444
4444444FDF444444
444444FDDDF44444
4444FDDDDDDDF444
DDDDDDDDDDDDDDDD
DDDDDDDDDDDDDDDD
DDDDDDDDDDDDDDDD
DDDDDDDDDDDDDDDD
CCDDDCCCCCDDDCCC
CCCDCCCCCCCDCCCC
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC` ],
[ grass5, bitmap`
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC` ],
[ grass6, bitmap`
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC
..CCCCCCCCCCCCC.
....CCCCCCCCC...` ],
[ grass7, bitmap`
44444444444444..
444444444664444.
4444664446F64444
4446F64444664444
4446644444444444
4444444FDF444444
444444FDDDF44444
4444FDDDDDDDF444
DDDDDDDDDDDDDD44
DDDDDDDDDDDDDD44
DDDDDDDDDDDDDDD4
DDDDDDDDDDDDDDDD
CCDDDCCCCCDDDCCC
CCCDCCCCCCCDCCCC
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC` ],
[ grass8, bitmap`
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCD
CCCCCCCCCCCCCCDD
CCCCCCCCCCCCCCCD
CCCCCCCCCCCCCCCD
CCCCCCCCCCCCCCCD
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCDD
CCCCCCCCCCCCCCCD
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC` ],
[ grass9, bitmap`
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCD
CCCCCCCCCCCCCCDD
CCCCCCCCCCCCCCCD
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC
.CCCCCCCCCCCCCC.
...CCCCCCCCCCC..` ],
[ string1, bitmap`
..............22
.............221
............221.
...........221..
..........221...
.........221....
........221.....
.......221......
......221.......
.....221........
....221.........
...221..........
..221...........
.221............
221.............
21..............` ],
[ string2, bitmap`
2222222222222222
1111111111111111
................
................
................
................
................
................
................
................
................
................
................
................
................
................` ],
[ string3, bitmap`
22..............
122.............
.122............
..122...........
...122..........
....122.........
.....122........
......122.......
.......122......
........122.....
.........122....
..........122...
...........122..
............122.
.............122
..............12` ],
[ t_pen_head_stand, bitmap`
.......4D.......
......D4DD......
......4DDD......
......44DD......
...F66.DD.66F...
...666F4DF666...
...66664D6666...
...6666666666...
...F67766776F...
....57777775....
....77277277....
....72022027....
....7229C227....
....7799CC77....
....57722775....
.....777777.....` ],
[ t_pen_body_stand, bitmap`
.....122221.....
....57777775....
...5777777775...
...77712217755..
..7777222277755.
.775772222777555
7775712222177755
7757722222277755
7.777222222777.5
..777222222777..
..777122221777..
...7777777777...
....77777777....
......CC.CC.....
......99.99.....
...9999C.C9999..` ],
[ t_pen_head_walk, bitmap`
.......4D.......
......D44.......
......4D4.......
......44D.......
...F66.DD.6F....
...666F44F66....
...66664D666....
...666666666....
...F6776677F....
....57777775....
....77727727....
....77202202....
....77229C22....
....77799CC7....
....57772275....
.....777777.....` ],
[ t_pen_body_walk1, bitmap`
.....122221.....
....57777775....
...5777777775...
..777712217755..
.7777722227775..
.77577222277755.
.77571222217775.
.75772222227775.
.77772222227775.
..777222222777..
..777122221777..
...7777777777...
....77CC7777....
......99.CC.....
......C9999.....
.........C9999..` ],
[ t_pen_body_walk2, bitmap`
.....122221.....
....57777775....
...5777777775...
..777712217755..
.7777722227775..
.77577222277755.
.77571222217775.
.75772222227775.
.77772222227775.
..777222222777..
..777122221777..
...7777777777...
....77777CC7....
......CC.99.....
......99.C9999..
......C9999.....` ],
[ m_pen_head_stand, bitmap`
................
................
................
................
................
................
................
................
................
................
......4DD.......
.....D4DDD......
.....4DDDD......
.....44DDD......
.....D4DDD......
.....4DDDD......` ],
[ m_pen_body_stand, bitmap`
....6F4DDF6F....
...6664DD66F....
...6264DD66F....
..F2666D666FF...
..66F76F67FFF...
..6F7776777FF...
..F772212277F...
..57202220275...
.7772299922755..
.7777777777755..
777712222217555.
775722222227555.
7..7222222275.5.
7...1222221...5.
....C9...9C.....
..9999...9999...` ],
[ m_pen_head_walk, bitmap`
................
................
................
................
................
................
................
................
................
................
......44D.......
.....D44DD......
.....4D4DD......
.....44DDD......
.....D44DD......
.....4D4DD......` ],
[ m_pen_body_walk1, bitmap`
....6F4DDF6F....
...666D4D66F....
...6266FD66F....
..F26666F66FF...
..66F76667FFF...
..6F7776777FF...
..F772212277F...
..57220222075...
.7772229992755..
.7777777777755..
77771222221755..
77572222222755..
7..72222222755..
7...1922221..5..
.....9999.......
.......CCCC.....` ],
[ m_pen_body_walk2, bitmap`
....6F4DDF6F....
...666D4D66F....
...6266FD66F....
..F26666F66FF...
..66F76667FFF...
..6F7776777FF...
..F772212277F...
..57220222075...
.7772229992755..
.7777777777755..
77771222221755..
77572222222755..
7..72222222755..
7...1222221..5..
.....9.CCCC.....
.....9999.......` ],
[ emperor1, bitmap`
...........66666
..........66FFF3
.........66F6CCC
.........446644C
........4446D444
.......444464444
.......D44464444
.......8D4434444
.......8HHD34444
......5H0288HH88
......58288820H8
......5H5585528H
......55558555H5
......1558755822
......5557755522
......5517715512` ],
[ emperor2, bitmap`
6666666FF.......
3333C66FF.......
33333C66FF......
CC333366FF......
4CC333C66FF.....
44CC33366FF.....
44CC333C66FF....
4DCC333366FF....
D55CC333C66FF...
555CC333366FF...
555CCC333666F...
55CCCC333C66F...
5221CC333366F...
2222CCC33366F...
2221DCC33366F...
2214DDCC3366F...` ],
[ emperor3, bitmap`
......5527725552
......552222555D
......55222D1554
......15D2444444
.....44441444444
....8HD4222222D4
....H82271177122
......7772277777
......1772277777
....C337712777C3
....333775C77533
....333777C77733
....C33177C17723
...FFFFF72FF722F
....FFFF22FF222F
.....FF222FF22FF` ],
[ emperor4, bitmap`
1444DDCC3366F...
4444DDCC3366F...
4444DDCC3C66F...
444DDDCC3666F...
444DDCC3C666F...
48HDDCC36666F...
2H8FFC3C6666F...
666FFFFFFFFFF...
66FFFFFFFFFFF...
66FFFFFFFFF.....
66FFF666FFFF....
66FFF66666FFF...
66FFFF66666FF...
F66FFF666666F...
FF66FFFFFFFFF...
FF66FFFFFFFFF...` ],
[ bg,bitmap`
7777777777777777
7777777777777777
7777777777777777
7777777777777777
7777777777777777
7777777777777777
7777777777777777
7777777777777777
7777777777777777
7777777777777777
7777777777777777
7777777777777777
7777777777777777
7777777777777777
7777777777777777
7777777777777777`]
)
setBackground(bg)
setSolids([p_stand,p_step1,p_jump2,p_swing,p_jump1,p_head3,p_step2,p_hat,p_ride1,p_yoyo,p_ride2,
          p_yoyo,grass1, grass4,grass7,grass5,grass6,crate])
setPushables({[p_stand]:[crate]})
let isJumping = false
let coinPos = {1: [13,6],2:[42,16],3:[16,9]}

let deader = false
let level = 1
let coincount = 0
setInterval(()=>{
  
  // console.log(getTile(coinPos[2][0], coinPos[2][1]))
  getFirst(p_head2).y = getFirst(p_stand).y -1
  getFirst(p_head2).x = getFirst(p_stand).x
  if(getTile(coinPos[1][0], coinPos[1][1]).length==2){
    
    level++
    
    setMap(map `
..........................................ë.....................
................................................................
................................................................
................................................................
................................................................
................................................................
................................................................
................................................................
................................................................
................Ú...............................................
................ë...............................................
............ë...ë...............................................
............ë..ëë...............................................
............ë...ë...............................................
............ëë..ë...............................................
............ë...ë...............................................
............ë..ëë.........................Ú.....................
............ëë..ë....................îîîîîîî....................
............ë...................................................
............ë................îîîîîî.............................
............ëëëëë...............................................
........................îîîî....................................
...................îîîî.........................................
................................................................
.........................îîîîî..................................
.............îîî...............îîîîî............................
.........P...ëëë................................................
.........s...ëëë.....................îîîîî......................
.......êêêêêêëëë................................................
.......ëëëëëëëëë................îîîî............................
.......ëëëëëëëìë...........îîî..................................
.......ìëëëëìë.ì...........ëëë..................................
........ëëëë.ë.............ëëë..................................
........ëëëë.ì.........Ð...ëëë..................................
........ëëëì.........êêêêêêëëë..................................
........ìëë..........ëëëëëëëëë..................................
.........ìë..........ëëëëëëëëë..................................
..........ë..........ìëëëëëëìë..................................
..........ì...........ëëëëëë.ì..................................
......................ìëìëìë....................................
.......................ë.ì.ë....................................
.......................ë....ì...................................
.......................ì........................................
................................................................
................................................................
................................................................
................................................................
................................................................
................................................................
................................................................
................................................................
................................................................
................................................................
................................................................
................................................................
................................................................
................................................................
................................................................
................................................................
................................................................
................................................................
................................................................
................................................................
................................................................`)
    coincount++
  }else if(getTile(coinPos[2][0], coinPos[2][1]).length == 2){
    if(coincount == 2){
      setMap(map `
...........................
...........................
...........................
...........................
...........................
...........................
...........................
...........................
...........................
...........................
...........................
...........................
...........................
...........................
...........................
...........................
...........................
...........................
...........................
...........................
...........................
...........................
...........................
...........................
...........................`)
    }
    coincount++
  }
    else if(getTile(coinPos[3][0], coinPos[3][1]).length == 2){
    if(coincount == 2){
      
    }
    coincount++
    
  }
},2)
setInterval(()=>{
  
  if(deader) return;
  isDead()
  if(isJumping) return;
  if(deader) return;
   
  getFirst(p_stand).y += 1
  getFirst(p_head2).y = getFirst(p_stand).y -1
  getFirst(p_head2).x = getFirst(p_stand).x
 
  
},100)
function isDead(){
  if(getFirst(p_head2).y  > 7 && level == 1){
    dead()
  }
  if(getFirst(p_head2).y  > 50 && level == 2){
    dead()
  }
}
function dead(){
  deader=true
  // console.log('test')
  setMap(map `
.............................
.............................
.............................
.............................
.............................
.............................
...........bbb...............
....b...b..b.b...............
....b...b..b.b...............
....b...b..b.b...............
....b...b..bbb...............
....b...b..bb................
....b...b..bbb...............
....b...b..b..bb.............
....bb.b...b...bb............
.....bbb...b.....b...........
..................b..........
.............................
.............................
.............................
....bbbb..bbbb.....bb........
....b..bb.b........bb....bbb.
....b...b.bb.......b.b..bb.b.
....b...b.b.bbbbb.bb.b..b...b
....b...b.b.......b..b..b...b
....b..b..b.......bbbb..b...b
....b..b..b.......b..b..b..bb
....b.bb...bbbbbb.b..b..b..b.
....bbb..................bbb.
.............................
.............................
.............................
ps...........................`)
  setBackground()
}
onInput("d", ()=>{
   if(deader) return
  
  // getFirst(p_head2).x +=1
  getFirst(p_stand).x += 1
 })
onInput("a", ()=>{
   if(deader) return
  
  // getFirst(p_head2).x -=1
  getFirst(p_stand).x -=1
 })
onInput("w",()=>{
  if(isJumping) return;
  if(deader) return
  isJumping = true
  for(let i= 0; i<6; i++){
    
    
    setTimeout(()=>{
      if(i==5){
      isJumping = false
    }
      if(i<3){
         getFirst(p_stand).y -=1
      getFirst(p_head2).y = getFirst(p_stand).y -1
      }else{
        getFirst(p_stand).y +=1
      getFirst(p_head2).y = getFirst(p_stand).y -1
        
      }
      
      
      
    },i*100)
  }
 
})
onInput("j", ()=>{
 coincount= 0
  setBackground(bg)
  level = 0

  setMap(map`
................
................
................
................
................
.P.....îî.......
.s...îîëëî...Ú..
îîîî.ëëëëë...ããã
ëëëë.ìëëëì...ëëë
.ìì...ììì....ëëë
.............ëëë
.............ëëë
.............ëëë
.............ëëë
.............ëëë
.............ëëë`)
   deader = false
 })
  setMap(map`
................
................
................
................
................
.P.....îî.......
.s...îîëëî...Ú..
îîîî.ëëëëë...ããã
ëëëë.ìëëëì...ëëë
.ìì...ììì....ëëë
.............ëëë
.............ëëë
.............ëëë
.............ëëë
.............ëëë
.............ëëë`)
